import { get, deleted, putJSON, postJSON } from '@/utils/request'
import type { Cate } from '@/types'
export const getCateList = async (): Promise<Cate[]> => {
  const data = await get('/my/cate/list')
  return data.data as unknown as Cate[]
}

export const addCate = async (cate: Cate) => {
  await postJSON('/my/cate/add', cate)
}

export const updateCate = async (cate: Cate) => {
  await putJSON('/my/cate/info', cate)
}

export const getCateInfo = async (id: number): Promise<Cate> => {
  const data = await get('/my/cate/list', { id: id })
  return data as unknown as Cate
}

export const delCate = (id: number) => {
  deleted('/my/cate/del', { id: id })
}
